import request from '@u/request'
import { HttpMethod } from '@u/http'

// 查询字典列表
export function listDict(query) {
  return request({
    url: `/sys/dict/list`,
    method: HttpMethod.GET,
    params: query
  })
}

// 查询字典详细
export function getDict(dictId) {
  return request({
    url: '/sys/dict/' + dictId,
    method: HttpMethod.GET
  })
}

// 新增字典
export function addDict(data) {
  return request({
    url: '/sys/dict',
    method: HttpMethod.POST,
    data: data
  })
}

// 修改字典
export function updateDict(data) {
  return request({
    url: '/sys/dict',
    method: HttpMethod.PUT,
    data: data
  })
}

// 删除字典
export function delDict(dictId) {
  return request({
    url: '/sys/dict/' + dictId,
    method: HttpMethod.DELETE
  })
}

// 清理参数缓存
export function clearCache() {
  return request({
    url: '/sys/dict/clearCache',
    method: HttpMethod.DELETE
  })
}

// 获取字典选择框列表
export function getOptionSelect() {
  return request({
    url: '/sys/dict/getOptionSelect',
    method: HttpMethod.GET
  })
}

// 根据字典编码查询
export function getDictByCode(dictCode) {
  return request({
    url: '/sys/dict/code/' + dictCode,
    method: HttpMethod.GET
  })
}
